package com.wangyi.sdk;

/**
 * 
 * @author vernon 20130407 实现Serializable接口 ,添加userid字段,并添加相应的get,set 方法
 */
public class OAuth2AccessToken {

	/**
	 * 
	 */
	private long expires_in;
	private String refresh_token;
	private String access_token;
	private long user_id;

	public long getUser_id() {
		return user_id;
	}

	public void setUser_id(long user_id) {
		this.user_id = user_id;
	}

	public OAuth2AccessToken() {
	}

	public OAuth2AccessToken(Response response) throws TBlogException {
		JSONObject json = response.asJSONObject();
		try {
			this.expires_in = json.getLong("expires_in");
			this.refresh_token = json.getString("refresh_token");
			this.access_token = json.getString("access_token");
		} catch (JSONException je) {
			throw new TBlogException(je.getMessage() + ":" + json.toString(), je);
		}
	}

	public long getExpires_in() {
		return expires_in;
	}

	public void setExpires_in(long expires_in) {
		this.expires_in = expires_in;
	}

	public String getRefresh_token() {
		return refresh_token;
	}

	public void setRefresh_token(String refresh_token) {
		this.refresh_token = refresh_token;
	}

	public String getAccess_token() {
		return access_token;
	}

	public void setAccess_token(String access_token) {
		this.access_token = access_token;
	}

	@Override
	public String toString() {
		return "expires_in=" + expires_in + " refresh_token=" + refresh_token + " access_token=" + access_token;
	}
}
